

/** YJWidgetFactory.cpp
 YJWidgetFactory::YJWidgetFactory
 yjwidgetfactory_binding.c
 yjwidgetfactory_binding.h
 YJWidgetFatctoryInterface
 **/


/**
 * TODO
 *
 * pamatovat si stav - parsuji konstruktor, funkci, zacatek konec, autogenerovaneho kodu
 * detekovat zacatek konstruktoru, funkce a konec. Dopsat generovatny kod
 * 
 * 
 * 
 */
println "hello world"



if (test()){
	process()
}

public void process(){
	
	
	
	def natives = new File("src_native");
	def nativeFilter = ~/Y.*\.cpp/
	def processFile = {file ->
		ParsedClass parser = new ParsedClass(file.getName());
		println "processing file: "+file.getName()
		file.eachLine{
			println "processing line: $it"
			parser.parseLine(it)
		}
		return parser	
	}
	def parser = processFile (new File("src_native/YJCheckBoxFrame.cpp"))
	parser.dump();
}

/**
 * inclass test suite
 */
public boolean test(){
	println "starting self test"
	
	def constructor ="YJCheckBoxFrame::YJCheckBoxFrame(YWidget * parent, const string &label, bool checked)"
	def constructorEnding =" 	:YAlignment(parent, horAl, vertAl) {"
	def function = "void YJAlignment::moveChild(YWidget* label, int x, int y){"
	def ending1 = "}"
	def ending2 = "std.system.cout asdkjf; << asldfkjas ; }"
	def ending3 = "std.system.cout asdkjf; << asldfkjas ; }  "
	def ending4 = "std.system.cout asdkjf; << asldfkjas ; }		"
	
	
	ParsedClass parser = new ParsedClass("Test.cpp");

	assert parser.shortName == "Test", "shortName is set correctly"
	assert parser.getFunctionName(function)=="moveChild", 'function name is broken'
	assert parser.getReturnType(function)=="void", "return type is broken"
	assert parser.getParams(function)=="YWidget* label, int x, int y", "get params is broken"
	assert parser.getTranslatedParams("YWidget* label, int x, int y")=="int id, int x, int y", "param translation works"
	assert parser.getCTypeDef(function)=="typedef void (* movechild)(int id, int x, int y);", "typedef for function is broken"
	assert parser.isFunction(function)==true, "function detection is broken"
	assert parser.isFunction(constructor)==false, "function detection was deceived by constructor"
	
	
	/*constructor tests */ 
	assert parser.getParams(constructor)=="YWidget * parent, const string &label, bool checked", "get params is broken ${parser.getParams(constructor)}"
	assert parser.isConstructor(constructor)==true, "constructor detection is broken"
	assert parser.isConstructor(function)==false, "function is not constructor!"
	
	assert parser.isEndOf(ending1)==true, "simple ending works"
	assert parser.isEndOf(ending2)==true, "complex ending works"
	assert parser.isEndOf(ending3)==true, "spaces ending works"
	assert parser.isEndOf(ending4)==true, "tabs ending works"
	
	println "self test finished"
	return true;
//	println getCTypeDefConstructor("YJCheckBoxFrame::YJCheckBoxFrame( YWidget * parent, const string &label, bool checked )YJCheckBoxFrame::YJCheckBoxFrame( YWidget * parent, const string &label, bool checked )")
}




